package initialize

import (
	"go.uber.org/zap"
	"user_bff/global"
)

func NewLogger() (*zap.Logger, error) {
	flag := GetSystemConfig()
	if flag {
		config := zap.NewProductionConfig()
		config.OutputPaths = []string{
			global.ServerConfig.LogConfig.Path,
		}
		return config.Build()
	} else {
		development, err := zap.NewDevelopment()
		if err != nil {
			return nil, nil
		}
		return development, err
	}
	return nil, nil
}
func LoggerConfig() {
	logger, err := NewLogger()
	if err != nil {
		return
	}
	zap.ReplaceGlobals(logger)
}
